<template>
    <div class="box">
      <!-- 省略其他内容 -->
      <el-table ref="table" border :data="list" style="width: 96%; margin-top: 20px;" :row-class-name="tableRowClassName">
        <!-- 定义表格列 -->
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column align="center" prop="accessorys" label="考核对象" width="180"></el-table-column>
        <el-table-column align="center" prop="markss" label="申诉原因" width="285"></el-table-column>
        <!-- 其他列 -->
      </el-table>
      <el-button type="danger" icon="el-icon-delete" plain size="mini" style="margin-left: 40px" @click="handleDelete">删除</el-button>
    </div>
  </template>
  
  <script>
  import { getjiafenshen, deleted } from "../../../api/zhenfu/audit";
  
  export default {
    data() {
      return {
        list: [],
        year: 2024,
        selectedStatus: ''
      };
    },
    created() {
      this.fetchData();
    },
    methods: {
      async fetchData() {
        try {
          const response = await getjiafenshen();
          if (response && response.result && response.result.message) {
            this.list = JSON.parse(response.result.message);
          }
        } catch (error) {
          console.error('Error fetching data:', error);
        }
      },
      async handleDelete() {
        const selectedRows = this.$refs.table.selection;
        if (selectedRows.length === 0) {
          this.$message.warning('请先选择一行数据');
          return;
        }
        
        const markssArray = selectedRows.map(row => row.markss);
        try {
          await deleted({ markss: markssArray });
          this.$message.success('删除成功');
          this.fetchData(); // 重新获取数据
        } catch (error) {
          console.error('删除失败:', error);
          this.$message.error('删除失败');
        }
      },
      handleChange(value) {
        // 处理年份变更逻辑
      },
      handleStatusChange(value) {
        // 处理状态变更逻辑
      },
      tiaozhuan() {
        // 处理预审核按钮点击逻辑
      }
    }
  };
  </script>
  
  <style scoped>
  .box {
    margin-left: 30px;
    margin-top: 20px;
  }
  </style>
  